<script type="x-template" id="overview-consumer">
	<div class="content">
		<Breadcrumb>
	        <Breadcrumb-item>服务概览</Breadcrumb-item>
	        <Breadcrumb-item>消费者</Breadcrumb-item>
	    </Breadcrumb>
	    <div style="height:8px;"></div>
		<i-table v-bind:columns="columns" v-bind:data="values"></i-table>
	</div>
</script>
<script>
	(function(){
		
		var initData = function(){
			var self = this;
			var http = this.$http;
			var error = function(){
				self.$Notice.error({
	                title:"温馨提示",
	                desc:"数据读取失败"
	            });
			};
			http.post("${base}/api/services.json").then(function(res){
				if(res.status === 200){
					var temp = res.data || {};
					var data = [];
					for(var key in temp){
						var protocol = key.substring(0,key.indexOf("://"));
						var type = key.substring(key.indexOf("://")+3,key.indexOf("("));
						var bean = key.substring(key.indexOf("(")+1,key.indexOf(")"));
						var hasConsumer = false;
						var item = temp[key];
						for(var k in item){
							if(item[k].consumer && item[k].consumer === true){
								hasConsumer = true;
								break;
							}
						}
						if(hasConsumer){
							data.push({
								protocol:protocol,
								type:type,
								bean:bean
							});
						}
					}
					self.values = data;
				}else{
					error();
				}
			}).catch(error);
		};
		Vue.component("overview-consumer",{
			template:"#overview-consumer",
			data:function(){
				initData.apply(this);
				return {
					columns:[
						{title:"ID",key:"_index",width:80,render:function(h,v){
							return v.index+1;
						}},
						{title:"协议",key:"protocol"},
						{title:"类型",key:"type"},
						{title:"名称",key:"bean"}
					],
					values:[]
				}
			}
		});
		routes.push({path:"/overview/consumer",component:Vue.component("overview-consumer")});
		
	})();
</script>